﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Physio10Context;
using DatabaseManager;

namespace Physio_Clinic
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        Doctor doctor = null;
        public Qf8soUser currentUser = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] != null)
            {
                currentUser = (Qf8soUser)Session["currentUser"];
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("./DoctorDetail.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            if (Session["currentDoctor"] != null)
            {
                Response.Redirect("./DoctorDetail.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["currentDoctor"] != null)
            {
                PersistentManager.Instance.Delete((Doctor)Session["currentDoctor"]);
                PersistentManager.Instance.Save();
            }

            Response.Redirect("./Doctor.aspx");
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (GridView1.SelectedRow != null)
            {
                string value1 = GridView1.SelectedRow.Cells[1].Text;

                doctor = PersistentManager.Instance.GetDoctor(Convert.ToInt32(value1));

                Session["currentDoctor"] = doctor;

                Button2.Enabled = true;
                Button3.Enabled = true;

            }
        }
    }
}